***** RUN DO_MASTER.do ***** do "$Do_files\DO_MASTER.do"

global program "Main_Table1"
cap log close
cap log using "$Log_files\log_$program$today", replace

**** REPLICATION OF TABLE 1 ****

clear all
set mem 2g
set more off

// Import data

use $Data\data_crime_news, clear

// Individual controls vector

global i_controls "age age2 i.sex_cd_p relation_* i.recidive_p pk_article_cd111 pk_article_cd112 pk_article_cd113 pk_article_cd116 pk_article_cd117 pk_article_cd137 pk_article_cd187" //

// Column 1

reghdfe coverage_nat pk_F_p							$i_controls, absorb(pk_wy pk_dow pk_commune newspaper) cluster(pk_case)
estimates store etr
sum coverage_nat if e(sample)
estadd scalar F1 = r(mean)

// Column 2

eststo: reghdfe coverage_nat pk_F_p 	readershare			$i_controls, absorb(pk_wy pk_dow pk_commune newspaper) cluster(pk_case)
estimates store readershare
sum coverage_nat if e(sample)
estadd scalar F1 = r(mean)

// Column 3

eststo: reghdfe coverage_nat pk_F_p 	Ddist_min			$i_controls, absorb(pk_wy pk_dow pk_commune newspaper) cluster(pk_case)
estimates store Ddist_min
sum coverage_nat if e(sample)
estadd scalar F1 = r(mean)

// Column 4

eststo: reghdfe coverage_nat pk_F_p readershare	Ddist_min   $i_controls, absorb(pk_wy pk_dow pk_commune newspaper) cluster(pk_case)
estimates store all
sum coverage_nat if e(sample)
estadd scalar F1 = r(mean)

// Export table

estout etr readershare Ddist_min all  ///
	using "$Results\\$program.tex", replace style(tex) type label	///
	cells(b(star fmt(%9.3f)) se(par fmt(%9.3f)))  ///
	stats(N r2 F1, lab("Observations" "$ R^2 $" "Sample mean (News coverage)") fmt(0 3 3)) ///  
	collabels(none) /// 
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels($^c$ .1 $^b$ .05 $^a$ .01) ///
	keep(pk_F_p readershare Ddist_min ) /// 
	order(pk_F_p readershare Ddist_min ) ///
	varlabels(pk_F_p "Foreign perpetrator" readershare "[0.5em] Readershare" Ddist_min "[0.5em] Newspaper HQ area") ///
	title(Crime news provision) ///	
	prehead("\begin{table}[!h]" ///
	"\begin{center}" ///
	"\begin{threeparttable}" ///
	"\begin{small}" ///
	"\caption{@title\label{$program}}" ///
	"\begin{tabular*}{\columnwidth}{@{\extracolsep{\stretch{1}}}l*{@M}{c}@{}}" ///
	"\hline" "\hline" ///	
	"\\" ///
	"Dependent Variable		&\multicolumn{4}{c}{News coverage}\\" ///
	"						\cmidrule(lr){2-5}	" ///
	"						&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)}  &\multicolumn{1}{c}{(3)}   &\multicolumn{1}{c}{(4)} \\") ///
	posthead("\hline" ///
	"\\") ///
	prefoot("\\" ///
	"\hline") ///
	postfoot("\hline" "\hline" ///
	"\end{tabular*}" /// 
	"\end{small}" ///
	"\begin{tablenotes}[normal,flushleft]" ///
	"\begin{scriptsize}" ///
	"\item \emph{Notes}:" /// 
	"The unit of observation is a perpatetrator $ \times $ newspaper dyad. " /// 
	"Standard errors clustered at crime event level in parentheses. " /// 
	"{$^c$} significant at 10\%; {$^b$} significant at 5\%; {$^a$} significant at 1\%. " /// 
	"Linear probability model estimations. " /// 
	"Individual characteristics of the perpetrator are included: age, age squared, gender, connection to the victim, and whether the perpetrator is a recidivist. " /// 
	"Calendar day, year-week, criminal code article, municipality, and newspaper fixed effects are included. " /// 
	"\end{scriptsize}" ///
	"\end{tablenotes}" ///
	"\end{threeparttable}" ///
	"\end{center}" ///
	"\end{table}")

cap log close
